/**
 * Created with IntelliJ IDEA.
 * User: suntao
 * Date: 16-10-12
 * Time: 下午5:34
 * To change this template use File | Settings | File Templates.
 */
$(function () {
    $("#pair_id").hide();
    var pair_id = $("#pair_id").text();

//    var type;
//    if (pair_id == undefined || pair_id == "" || pair_id == null) {
//        // 添加
//        type = 1
//    } else {
//        // 编辑
//        type = 2;
//    }
    $("#save").click(function() {
        var jsonContent = $("#pair_json_content").val().trim();
        transDevicePairSNInfoSubmit(1, pair_id, jsonContent);
    });
});

function transDevicePairSNInfoSubmit (type, id, jsonContent) {
    $.ajax({
        url: "saveTransDevicePairSNInfo.do",
        type: "post",
        async: true,
        data:"type=" + type + "&id=" + id + "&pairJson=" + jsonContent,
        dataType: "json",
        success: function (data) {
            if (data["code"] == "1000") {
                location.replace(location.href);
            } else {
                layer.msg('添加失败!', {icon: 5, time: 1000});
            }
        },
        error: function (data) {
            layer.msg('操作失败!', {icon: 2, time: 1000});
        }
    });
}